<?php
require_once('tpl/head.php');
include_once('./system/dbConn.php');
?>
<?php 
connect();
//接收vid参数，写SQL语句获取当前的视频信息，更新点击量
$vid=$_GET["vid"];
$sql="select * from videos join videotype on videos.tid=videotype.tid join admins on videos. uploadadmin=admins.adminid where vid=$vid";
//echo $sql;
$result=mysql_query($sql);
$row=mysql_fetch_assoc($result);

//更新点击次数
$sqlhit="update videos set hittimes=hittimes+1 where vid=$vid";
$resulthit=mysql_query($sqlhit);

 ?>
}
<!-- 请登录后留言的登录，登录后返回的不是主页面 -->
<div class="modal fade" id="login1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">用户登录1</h4>
      </div>
      <div class="modal-body">

    <form class="form-horizontal" action="doUserLogin.php" method="POST" >
    <input type="hidden" name="vid" value="<?php echo $vid; ?> ">
  <div class="form-group">
    <label for="inputName3" class="col-md-2 control-label">用户名</label>
    <div class="col-md-6">
      <input type="text" class="form-control" id="inputName3" name="username" placeholder="用户名">
    </div>
  </div>


  <div class="form-group">
    <label for="inputPassword3" class="col-md-2 control-label">密码</label>
    <div class="col-md-6">
      <input type="password" class="form-control" id="inputPassword3" name="password" placeholder="密码">
    </div>
  </div>

  

  
  <div class="form-group">
    <div class="col-md-offset-2 col-md-10">
      <input type="submit" value="登录" class="btn btn-default">
      
    </div>
  </div>
</form>




      </div>
      <div class="modal-footer">
                <button type="button" class="btn btn-default" onclick="location.replace('index.php')" data-dismiss="modal">关闭</button>
      </div>
    </div>
  </div>
</div>  

<div class="container">

    <div class="row row-offcanvas row-offcanvas-right">

        <div class="col-xs-12 col-sm-12">


            <div class="row box">
                <div class="col-lg-4 text-center">
                   <video width="100%" height="100%" controls="controls" poster="./posters/<?php echo $row["pic"]; ?>">
                       <source src="<?php 
                       echo $row["address"]; ?>" type="video/mp4">
                       </source>
                   </video>
                    
                    <p><?php echo $row["videoname"]; ?></p>

                </div><!--放视频海报和标题-->
                <div class="col-lg-8 text-center">
                    <table class="table table-hover">
                        <tr class="active">
                            <td>专栏</td>
                            <td><?php echo $row["typename"]; ?></td>
                            
                        </tr>
                         <tr class="active">
                            <td>上传时间</td>
                            <td><?php echo $row["uploaddate"]; ?></td>
                          
                        </tr>
                         <tr class="active">
                            <td>点击次数</td>
                            <td><?php echo $row["hittimes"]; ?></td>
                           
                        </tr>
                         <tr class="active">
                            <td>上传人</td>
                            <td><?php echo $row["adminname"]; ?></td>
                            
                        </tr>
                         <tr class="active">
                            <td>有事找站长</td>
                            <td><a href="mailto:1318948769@qq.com">意见箱</a></td>
                           
                        </tr>
                         <tr class="active">
                            <td>评分</td>
                            <td></td>
                            
                        </tr>
                    </table>


                </div><!--表格显示视频详细信息-->


            </div>
            <!--/row-->
            <div class="row box">

                <div class="col-lg-12">
                    <h2 class="intro-text text-center">内容简介

                    </h2>
                    <?php 
                  echo $row["intro"];
                     ?>


                </div>
            </div>  <!--/row-->

            <div class="row box">

                <div class="col-lg-12">
                    <h2 class="intro-text text-center">留言列表
                    </h2>

                    <?php 
                $sql1="select * from comments where vid=$vid";
                $result1=mysql_query($sql1);


                     ?>
                    <table class="table table-bordered">
                        <tr>
                            <th>序号</th>
                            <th>评论内容</th>
                            <th>发表评论的时间</th>
                            <th>评论人</th>
                        </tr>
                        <?php 
                while ($row1=mysql_fetch_assoc($result1)) {
                        
                         ?>
                          <tr>
                            <td><?php echo $row1["cid"];  ?></td>
                            <td><?php echo $row1["content"];  ?></td>
                            <td><?php echo $row1["cdate"];  ?></td>
                            <td><?php
                            $uid=$row1["uid"];
                             $sql2="select * from users where uid=$uid";
                             $result2=mysql_query($sql2);
                             $row2=mysql_fetch_assoc($result2);
                             echo $row2["uname"];
                              ?></td>
                        </tr>
                         <?php 
                           }
                          ?>
                       
                    </table>


                </div>
            </div>  <!--/row-->

              <div class="row box">

                <?php 
               // session_start();
                /*判断用户是否登录*/
                if (isset($_SESSION["username"])) {
                  ?>
             <div class="col-lg-12">
                    <h2 class="intro-text text-center">您的留言

                    </h2>
                    <form class="form-horizontal" action="doCommentAdd.php" method="post" >
        <input type="hidden" name="vid" value="<?php echo $vid; ?>   ">
                    <div class="form-group">
    <label for="inputEmail3" class="col-md-2 control-label"></label>
    <div class="col-md-12">
      <textarea class="form-control" rows="5" name="content"></textarea>
    </div>
  </div>
   <div class="form-group">
    <div class="col-md-offset-2 col-md-12">
      <input type="submit" value="发表留言" class="btn btn-default">    
    </div>
  </div>
                    </form>



                </div>
            </div>  

                  <?php
                }   
                else{
                    ?> 
                    <div class="col-md-12">
                        请<a href="#" data-toggle="modal" data-target="#login1">登录</a>后留言
                    </div>

                    <?php 

                }            
                 ?>
 

             
        <!--/.col-xs-12.col-sm-12-->

       
    </div>
    <!--/row-->

    

</div>
<!--/.container-->
<?php
require_once('tpl/foot.php');
include_once('./system/dbConn.php');
?>
